/* ThreadPool.java
 * Author: liuex
 * 2007-12-14 ����01:34:37
 *
 * Note: 
 */
package org.lex.swing.widgets.console.demo;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public class ThreadPool {
	private final static ThreadPool INSTANCE = new ThreadPool();

	public static ThreadPool getInstance() {
		return INSTANCE;
	}

	private ExecutorService pool = null;

	private ThreadPool() {
		this.pool = Executors.newCachedThreadPool();
	}

	public ExecutorService getExecutorService() {
		return pool;
	}

	public void execute(Runnable command) {
		pool.execute(command);
	}

	public <T> Future<T> submit(Callable<T> task) {
		return pool.submit(task);
	}

	public void shutdown() {
		pool.shutdown();
	}
}
